Ultrasonic 3 Click
Ultrasonic 3 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Oct 2025.
- Type : SPI type
Software Support
Example Description
This example demonstrates ranging with Ultrasonic 3 Click (Chirp/TDK time-of-flight). The example periodically triggers a measurement and prints the measured distance to the USB UART.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Ultrasonic3
Example Key Functions
- ultrasonic3_cfg_setup This function initializes Click configuration structure to initial values.
void ultrasonic3_cfg_setup(ultrasonic3_cfg_t *cfg)
Ultrasonic 3 configuration object setup function.
Ultrasonic 3 Click configuration object.
Definition ultrasonic3.h:140
- ultrasonic3_init This function initializes all necessary pins and peripherals used for this Click board.
err_t ultrasonic3_init(ultrasonic3_t *ctx, ultrasonic3_cfg_t *cfg)
Ultrasonic 3 initialization function.
Ultrasonic 3 Click context object.
Definition ultrasonic3.h:121
- ultrasonic3_default_cfg This function executes a default configuration of Ultrasonic 3 Click board.
err_t ultrasonic3_default_cfg(ultrasonic3_t *ctx)
Ultrasonic 3 default configuration function.
- ultrasonic3_get_measurements This function triggers and reads the measurements and logs data.
void ultrasonic3_get_measurements(void)
Ultrasonic 3 get measurements function.
Application Init
Initialize the USB UART logger and the Ultrasonic 3 driver, then apply the default configuration to start the sensor and prepare it for continuous single-shot ranging.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define ULTRASONIC3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ultrasonic3.h:105
void application_init(void)
Definition main.c:37
@ ULTRASONIC3_ERROR
Definition ultrasonic3.h:166
Application Task
Triggers a measurement and logs results (distance, sample number, and amplitude) every 100ms.
{
Delay_ms ( 100 );
}
void application_task(void)
Definition main.c:73
Note
Make sure to configure falling-edge external interrupt on INT pin in bsp.c for your selected setup. Currently, only 3 interrupts are pre-configured for the following setups:
- MCU Card for STM32 STM32F407ZG (MIKROBUS1)
- MCU Card for Tiva TM4C129XNCZAD (MIKROBUS1)
- MCU Card for PIC32 PIC32MX795F512L (MIKROBUS1)
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.